<!-- 记录组件  -->

<template>
	<view class="record">
		<view class="mb20">
			<view class="recordItem" v-for="(it,ind) in newList" :key="ind"
				@click="path(`/plugins/symptoms/index?data=${JSON.stringify(it)}&ci=${ind}`)">
				<view class="recordChild">
					<view @click.stop="delectTap(index,ind)" class="close">
						<image src="../../static/images/del.png" mode=""></image>
					</view>
					<view class="recordName">{{it.name}}</view>
				</view>
				<view class="recordChild">
					<view class="">{{it.where}}{{it.sname}}{{it.name}}</view>
					<view class="icon arrow"></view>
				</view>
			</view>
			<view class="recordItem">
				<view class="recordChild">
					<view class="close"></view>
					<view class="recordName">主诉</view>
				</view>
				<view class="recordChild" @click="path(`/plugins/symptoms/index?&ci=-1`)">
					<view class="">添加</view>
					<view class="icon arrow"></view>
				</view>
			</view>
		</view>
		<lk-timeperiod :show="showPeriod" @submit="submit" @cancel="cancel"></lk-timeperiod>
	</view>
</template>

<script>
	import lkTimeperiod from '../lk-timeperiod/index.vue'

	export default {
		name: "",
		data() {
			return {
				showPeriod: false,
				periodIndex: 0,
				startTime: '',
				endTime: ''
			}
		},
		props: {
			lists: {
				type: Array,
				default: () => {
					return []
				}
			},
			types: {
				type: String,
				default: ''
			},
			paths: {
				type: String,
				default: ''
			}
		},
		components: {
			lkTimeperiod
		},
		computed: {
			newList() {
				 this.lists.forEach(item => {
					this.$switch.sid(item);
					this.$switch.severity(item)
				})
				return this.lists;
			}
		},
		methods: {
			// 删除数据
			delectTap(index, ind) {
				let _this =this;
				uni.showModal({
					title:"提示",
					content:"确定要删除？",
					success(res){
						if(res.confirm){
							_this.$emit('delectTap',{index,ind})
						}
					}
				})
			},
			// 弹起时间弹窗
			selectTime(index) {

				this.showPeriod = true;
				this.periodIndex = index;
			},
			// 取消时间弹窗
			cancel() {
				this.showPeriod = false;
			},
			/** 时间弹窗点击确定
			 * @param {Object} e 子组件lkTimeperiod返回时间段
			 */
			submit(e) {
				this.lists[this.periodIndex].time = e;
				this.showPeriod = false;
			},
			// 页面跳转
			path(url) {
				console.log(url);
				this.$routeJump.navigateTo(url)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.recordItem {
		padding: 20rpx 0;
		font-size: 36rpx;
		@include flex(space-between, center);

		.recordChild {
			@include flex(flex-start, center) .recordName {
				width: 160rpx
			}
		}
		.close{
			width:46rpx;
			height: 46rpx;
			margin-right: 14rpx;
		}
	}
</style>
